<template>
  <div>
    <el-container>
      <el-aside width="200px">
        <div>管理系统</div>
        <div>
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            @select="handleSelect"
          >
            <el-menu-item index="2">
              <i class="el-icon-menu"></i>
              <span slot="title">首页</span>
            </el-menu-item>
            <el-menu-item index="3">
              <i class="el-icon-document"></i>
              <span slot="title">商品管理</span>
            </el-menu-item>
            <el-menu-item index="4">
              <i class="el-icon-setting"></i>
              <span slot="title">用户管理</span>
            </el-menu-item>
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>其他</span>
              </template>
              <el-menu-item-group>
                <el-menu-item index="1-1">页面1</el-menu-item>
              </el-menu-item-group>
              <el-menu-item-group>
                <el-menu-item index="1-3">页面2</el-menu-item>
              </el-menu-item-group>
            </el-submenu>
          </el-menu>
        </div>
      </el-aside>
      <el-container>
        <!-- 顶部导航栏 -->
        <el-header>
          <el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }"
              ><i class="el-icon-menu"></i>首页</el-breadcrumb-item
            >
            <el-breadcrumb-item><a href="/">商品管理</a></el-breadcrumb-item>
            <el-breadcrumb-item>用户管理</el-breadcrumb-item>
            <el-breadcrumb-item>页面1</el-breadcrumb-item>
            <el-breadcrumb-item>页面2</el-breadcrumb-item>
          </el-breadcrumb>
          <!-- 头像登录 -->
          <div class="demo-type">
            <el-avatar icon="el-icon-user-solid"></el-avatar>
          </div>
        </el-header>
        <el-main>
          <!-- 小导航栏 -->
          <el-row :gutter="20">
            <el-col :span="6">
              <div class="grid-content bg-purple">首页</div>
              <!-- <div class="grid-content bg-purple" v-for="item, index in lis" :key="index">{{ item }}</div> -->

              <div class="tags">
                <el-tag
                  :key="tag"
                  v-for="tag in dynamicTags"
                  closable
                  :disable-transitions="false"
                  @close="handleClose(tag)"
                >
                  {{ tag }}
                </el-tag>
                <el-input
                  class="input-new-tag"
                  v-if="inputVisible"
                  v-model="inputValue"
                  ref="saveTagInput"
                  size="small"
                  @keyup.enter.native="handleInputConfirm"
                  @blur="handleInputConfirm"
                >
                </el-input>
                <el-button
                  v-else
                  class="button-new-tag"
                  size="small"
                  @click="showInput"
                  >+ New Tag</el-button
                >
              </div>
            </el-col>
          </el-row>

          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dynamicTags: ["商品管理", "用户管理", "其他", "页面一", "页面二"],
      inputVisible: false,
      inputValue: "",
    };
  },
  methods: {
    handleSelect(index, indexpath) {
      console.log(index, indexpath);
      if (index == 4) {
        this.$router.push("/user");
      }
      if(index==2){
        this.$router.push('./home')
      }
      //商品管理页面点击事件
       if (index == 3) {
        this.$router.push("/shop");
      }
    },
    //商品管理页面点击事件
    // users(index = 3) {
    //     this.$router.push('/shop2')
    // },
    handleClose(tag) {
      this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
    },
    showInput() {
      this.inputVisible = true;
      this.$nextTick((_) => {
        this.$refs.saveTagInput.$refs.input.focus();
      });
    },
    handleInputConfirm() {
      let inputValue = this.inputValue;
      if (inputValue) {
        this.dynamicTags.push(inputValue);
      }
      this.inputVisible = false;
      this.inputValue = "";
    },

    //飞页点击事件
    fly() {
      if (index == 3) {
      }
    },
  },
};
</script>

<style lang="less" scoped>
.el-header {
  background-color: #8ae89e;
  color: #333;
  text-align: center;
  line-height: 60px;

  // width: calc(100vh - 150px);
  .el-breadcrumb {
    line-height: 60px;
  }

  .demo-type {
    float: right;
    z-index: 1000;
    width: 50px;
    height: 70px;
    padding: 100px 200px -21px 1px;
    outline: 1px solid red;

    .el-avatar--icon {
      font-size: 28px;
    }
  }
}

.el-aside {
  background-color: #46586b;
  color: #fff;
  text-align: center;
  // line-height: 200px;
  height: calc(102vh - 30px);
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  // line-height: 160px;
  height: calc(95vh - 130px);
}

.el-menu {
  background-color: #46586b;
  color: #fff;

  .el-menu-item {
    color: #fff;
    background-color: #46586b;
  }

  .el-submenu span {
    color: #fff;
  }

  // hover效果
  .el-submenu__title:hover {
    background-color: #3d4d5e;
  }
}

.el-row {
  margin-bottom: 12px;

  &:last-child {
    margin-bottom: 0;
  }
}

.el-col {
  border-radius: 4px;
  width: 10%;

  .tags {
    width: 700px;
    margin: -32px 50px 0 140px;
    display: flex;
    flex-direction: row;
    justify-content: space-around;

    span {
      width: 90px;
    }
  }
}

.bg-purple-dark {
  background: #f1f1f4;
}

.bg-purple {
  background: #d3dce6;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
  margin-left: 8px;
  margin-top: -1px;
  text-align: center;
  line-height: 36px;
  background-color: #f9fafc;
  color: rgb(108, 224, 213);
  box-shadow: 0.2px 0.4px 1.1px 1.2px rgba(33, 184, 65, 0.3);
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

//小导航栏标签
.el-tag + .el-tag {
  margin-left: 10px;
}

.button-new-tag {
  margin-left: 10px;
  height: 32px;
  line-height: 30px;
  padding-top: 0;
  padding-bottom: 0;
}

.input-new-tag {
  width: 90px;
  margin-left: 10px;
  vertical-align: bottom;
}
</style>